<template>
    <div>
        <h3>房号列表</h3>
        房型名称
        <input type="text" v-model="can.houseNoNumber">
        <input type="button" value="查询" @click="getList" class="btn btn-success">
        
        <input type="button" value="增加" @click="add" class="btn btn-primary">
       

        <input type="button" value="导出" @click="exportFn" class="btn btn-warning">
        
        <input type="file" @change="imprtFn">
        <input type="button" value="导入" @click="abc" class="btn btn-warning">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>房号名称</td>
                    <td>房型名称</td>
                    <td>房型图片</td>
                    <td>价格</td>
                    <td>门店名称</td>
                    <td>房态</td>
                    <td>操作</td>
                </tr>
                <tr v-for="item in data.list">
                    <td>{{ item.HouseName }}</td>
                    <td>{{ item.HouseTypeName }}</td>
                    <td>
                        <img :src="item.Photo" width="150" height="100">
                    </td>
                    <td>{{ item.Price }}</td>
                    <td>{{ item.ShopName }}</td>
                    <td>{{ item.HouseState }}</td>
                    <Td>
                        <input type="button" class="btn btn-success" value="修改">
                        <input type="button" class="btn btn-danger" value="删除">
                    </Td>
                </tr>
            </tbody>
        </table>
        
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted, useSlots } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import moment from 'moment';
import axios from 'axios';
const route = useRoute();
const router = useRouter();

let can:any=reactive({
    pageIndex:1,
    PageSize:3,
    houseNoNumber:""
})
let data:any=reactive({
    list:[]
})

onMounted(()=>{
    getList();
})

const add=()=>{
    router.push('/housenoadd')
}
let obj=ref()
//导入
const imprtFn=(e:any)=>{
    obj.value=e.target.files[0];
}
const abc=()=>{
    let f=new FormData();
    f.append('file',obj.value);
    axios({
        method:"post",
        url:"/api/House/ImportExcel",
        data:f
    })
    .then(res=>{
        console.log(res);
    })
}
//导出
const exportFn=()=>{
    location.href=`https://localhost:7035/api/House/ExportExcel?pageIndex=${can.pageIndex}&PageSize=${can.PageSize}&houseNoNumber=${can.houseNoNumber}`;
}

const getList=()=>{
    axios({
        method:"get",
        url:"/api/House/GetHouseNoList",
        params:can
    })
    .then(res=>{
        data.list=res.data.list;
    })
    .catch(err=>{
        console.log(err);
    })
}




</script>













<style scoped></style>